<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/27
 * Time: 17:12
 */

namespace app\api\controller;


use think\Controller;
use think\Db;

class Crontab extends Controller
{

    public function index(){


    }

    public function collageAction(){
        $data = Db::name('goods_collage')->where('status',0)->select();
        $time = time();
        if (!$data){
            return 0;
        }
        foreach ($data as $k=>$v){
            if ($time >= $data['create_time']){
                Db::name('goods_collage')->where('id',$v['id'])->update(['status'=>1]);
            }
        }
    }

    public function collageEnd(){
        $data = Db::name('goods_collage')->where('status',1)->select();
        $time = time();
        if (!$data){
            return 0;
        }
        foreach ($data as $k=>$v){
            if ($time >= $data['endtime']){
                Db::name('goods_collage')->where('id',$v['id'])->update(['status'=>2]);
            }
        }
    }

    public function orderEnd(){
        $data = Db::name('collage_group')->where('status',1)->select();
        $time = time();
        if (!$data){
            return 0;
        }
        foreach ($data as $k=>$v){
            if ($time >= $data['endtime']){
                Db::name('collage_group')->where('id',$v['id'])->update(['status'=>3]);
            }
        }
    }



}